﻿using Shinva.LADModel.Models;
using Shinva.Variables.Models;
using Shinva.Variables.Type.combination;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shinva.PLCModel.Models
{
    public class PlcOB
    {
        #region 变量表快速访问属性
        //输入变量列表
        public PlcStruct InputStruct { get; set; } = new PlcStruct() { Name = "Input" };

        // 临时变量列表
        public PlcStruct TempStruct { get; set; } = new PlcStruct() { Name = "Temp" };

        // 常量列表
        public PlcStruct ConstantStruct { get; set; } = new PlcStruct() { Name = "Constant" };
        #endregion

        /// <summary>
        /// 这个是OB块的编号，0号必须为Main块
        /// </summary>
        public int Number { get; set; }

        /// <summary>
        /// 这个是OB块的名称，0号必须为Main块
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 梯形图结构
        /// </summary>
        public Diagram LADTree { get; set; } = new Diagram();

        /// <summary>
        /// 这是接口变量表
        /// </summary>
        public NormalVariableTable InterfaceVariableTable { get; set; } = new NormalVariableTable();


        public PlcOB(int _num,string _name)
        {
            Number = _num;

            Name = _name+"["+"OB"+_num+"]";

            InterfaceVariableTable.AddMember(InputStruct);
            InterfaceVariableTable.AddMember(TempStruct);
            InterfaceVariableTable.AddMember(ConstantStruct);
        }
    }
}
